﻿/// <reference path="../core/jquery-1.4.2.min-vsdoc.js"/>
/// <reference path="../config/sw-config-default.js"/>
/// <reference path="../core/sw-prototype.js"/>
/// <reference path="../core/sw.js"/>
/// <reference path="../core/sw-control-core.js"/>

/***************************************************************************
jQuery sitemap
NOTE: Created for SmartUI. 
Copyright 2010, Roy zhang
Features：
1.Smart UI内嵌框架使用
2.
3.
4.
Update Note：

Needs：
****************************************************************************/

(function ($) {
    $.fn.sitemap = function (options) {
        /// <summary>pager</summary>
        /// <param name="options" type="Array">配置项</param>
        /// <param name="datas" type="Json">页面数据源</param>
        options = $.extend({
            container: iconfig.sitemap.container
            , item: iconfig.sitemap.item
            , cssFirst: 'sitemap_start'
            , cssCurrent: 'current'
        }, options);

        this.empty();
        var allUI = getAllPathUI();
        if (allUI) {
            var list = $(options.container).appendTo(this),
            jsnData = new Array();
            jsnData.push({ name: $page.site.name, ui: 'site' });
            $.each(allUI, function (i, name) {
                var ui = getJsonValue($page, name);
                if (ui) {
                    jsnData.push({ name: ui.name, ui: name });
                }
            });
            var items = ictrcore.teml(list, options.item, jsnData);
            $(items.get(0)).addClass(options.cssFirst);
            $(items.get(items.length - 1)).addClass(options.cssCurrent);
        }
        return this;
    };

})(jQuery);